package com.mo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mo.constant.Constants;
import com.mo.mapper.TCluemapper;
import com.mo.mapper.TTranmapper;
import com.mo.model.TTran;
import com.mo.query.BaseQuery;
import com.mo.service.TranService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author mo
 * version
 */
@Service
public class TranServiceImpl implements TranService {
    @Resource
    TTranmapper tTranmapper;
    @Resource
    TCluemapper tCluemapper;
    @Override
    public PageInfo<TTran> getTranByPage(Integer current) {
        //设置PageHelper
        PageHelper.startPage(current, Constants.PAGE_SIZE);
        //查询
        List<TTran> list = tTranmapper.selectTranByPage(BaseQuery.builder().build());
        PageInfo<TTran> info = new PageInfo<>(list);
        return info;
    }

    @Override
    @Transactional
    public int deleteTranById(Integer id) {

        return tTranmapper.deleteByPrimaryKey(id);
    }
}
